package com.lpwa.web.controller.system;

import java.util.List;

import com.lpwa.common.config.BasicConfig;
import com.lpwa.common.utils.StringUtils;
import com.lpwa.system.domain.SysEsmap;
import com.lpwa.system.service.ISysEsmapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import com.lpwa.common.config.Global;
import com.lpwa.common.core.controller.BaseController;
import com.lpwa.framework.util.ShiroUtils;
import com.lpwa.system.domain.SysMenu;
import com.lpwa.system.domain.SysUser;
import com.lpwa.system.service.ISysMenuService;

/**
 * 首页 业务处理
 * 
 * @author tanmu
 */
@Controller
public class SysIndexController extends BaseController
{
    @Autowired
    private ISysMenuService menuService;
    @Autowired
    private BasicConfig basicConfig;
    @Autowired
    private ISysEsmapService sysEsmapService;
    // 系统首页
    @GetMapping("/index")
    public String index(ModelMap mmap)
    {
        // 取身份信息
        SysUser user = ShiroUtils.getSysUser();
        // 根据用户id取出菜单
        List<SysMenu> menus = menuService.selectMenusByUser(user);
        mmap.put("menus", menus);
        mmap.put("user", user);
        mmap.put("ipAddress", Global.getWebsocketIpAndPort());
        mmap.put("onlineIpAddress", Global.getOnlineSocketIpAndPort());
        mmap.put("version", Global.getVersion());
        mmap.put("copyrightYear",Global.getCopyrightYear());
        return "index";
    }

    // 系统介绍
    @GetMapping("/system/main")
    public String main(ModelMap mmap)
    {
//        mmap.put("version", Global.getVersion());
        List<SysEsmap> sysEsmapList = sysEsmapService.selectSysEsmapList(new SysEsmap());
        if (!StringUtils.isEmpty(sysEsmapList)){
            mmap.put("sysEsmap", sysEsmapList.get(0));
        }
        return "mainIndex";
    }
    // 系统介绍
//    @GetMapping("/system/main")
//    public String main(ModelMap mmap)
//    {
////        mmap.put("version", Global.getVersion());
//        //获取地图配置数据
//        List<SysEsmap> sysEsmapList = sysEsmapService.selectSysEsmapList(new SysEsmap());
//        if (!StringUtils.isEmpty(sysEsmapList)){
//            mmap.put("sysEsmap", sysEsmapList.get(0));
//        }
//        return "main";
//    }
}
